package com.bihu.bihudemo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bihu.bihudemo.entity.Question;
import com.bihu.bihudemo.result.Result;
import com.bihu.bihudemo.service.QuestionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/timeline")
public class TimeLineController {
    @Resource
    QuestionService questionService;

    @GetMapping
    public Result getTimeLine(){

        QueryWrapper<Question> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("create_time");
        List<Question> list = questionService.list(wrapper);
        return Result.ok().put("Questionlist",list);
    }
}
